<?php
$uid	= "traviscon";	// Bot ID
$pwd	= "123456";	// Bot Pwd
$target	= "infoquyet";	// TargetID
$starttime  = microtime(true);

//load config
include "../includes/config/config.php";
//create object db
include "../includes/class_mysql.php";
include "../includes/gpc_function.php";
include('includes/functions.php');
include('includes/global.php');
include('includes/functions_sitemap.php');
include_once ("../includes/phpmailer/function.sendmail.php");
include 'includes/YMSG.class.php';	// YMSG Protocol Class

 
$enline         = "\n";
//check booking tour:
$idbookingmax   = intval(getConfig('BookingIdTourMax'));
$sql_select     = "select * from tblbooking where iId>$idbookingmax";
$rs             = $dbsql->query($sql_select);
$hasBookingTour = false;
$msgTour        = 'Booking Tour:'.$enline;
while($result=$dbsql->fetch_array($rs))
{
    $idbookingmax = $result['iId'];
    $hasBookingTour=true;
    $msgTour    .= 'Email: '.$result['cEmail'].$enline;
    $msgTour    .= 'Name: '.$result['cFName'].$result['cLName'].$enline;
    $msgTour    .= 'Tour: '.$result['cTourName'].$enline.$enline;
}

//check booking hotel:
$idbookhotelmax   = intval(getConfig('BookingIdHotelMax'));
$sql_select     = "select * from tblbookhotel where iId>$idbookhotelmax";
$rs             = $dbsql->query($sql_select);
$hasBookingHotel= false;
$msgHotel        = 'Booking Hotel:'.$enline;
while($result=$dbsql->fetch_array($rs))
{
    $idbookhotelmax = $result['iId'];
    $hasBookingHotel=true;
    $msgHotel    .= 'Email: '.$result['cEmail'].$enline;
    $msgHotel    .= 'Name: '.$result['cFName'].$result['cLName'].$enline;
    $msgHotel    .= 'Hotel: '.$result['cTourName'].$enline.$enline;
}

if($hasBookingTour==false && $hasBookingHotel==false)
{
    exit('notbook');
}
///////////////////////////////////////////////////   
$ymsg = new YMSG();
$ymsg->connect($uid,$pwd);

if($hasBookingTour)
{
    $ymsg->sendMsg($target,$msgTour);
    saveConfig('BookingIdTourMax',$idbookingmax);
}
	
if($hasBookingHotel)
{
    $ymsg->sendMsg($target,$msgHotel);
    saveConfig('BookingIdHotelMax',$idbookhotelmax);
}

?>
